<template>
  <div>
    <el-menu
      default-active="2" class="el-menu-vertical-demo" @open="handleOpen" router style="height:h"
      @close="handleClose" background-color="#4da1ff" text-color="#fff" active-text-color="#ffd04b">
      <template v-for="(item, index) in navArr">
        <el-menu-item :index="item.url" :key="index">
          <span slot="title">{{ item.title }}</span>
        </el-menu-item>
      </template>
      <!-- 这个槽口是给侧边栏底部的图标用的 -->
      <slot name="bottomicon"></slot>
    </el-menu>
  </div>
</template>

<script>
export default {
  props: {
    navArr: { type: Array, default: [] }, //侧边栏的标题内容
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style lang='less' scoped>
/deep/.el-menu {
  position: relative;
  border-right: none;
}
/deep/.el-menu-item {
  padding: 10px 20px;
  line-height: 37px;
}
</style>